/**
 * Copyright (c) 2007, Ashish Lijhara
 * All rights reserved.
 *
 * GradientUtils.java
 *
 */

package crazy.java.Aetas;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics2D;

/**
 *
 * @author Ashish (Java Crazy)
 */
public class GradientUtils{
    public static final int RECT_GRADIENT  					= 0;
    public static final int ROUND_RECT_GRADIENT				= 1;
    public static final int LIGHT_ROUND_RECT_GRADIENT		= 2;
    
    /**
     *
     * @param g2
     * @param x
     * @param y
     * @param w
     * @param h
     * @param wa
     * @param ha
     * @param type
     */
    public GradientUtils(Graphics2D g2,int x,int y,int w,int h,int wa,int ha,int type){
        if (type==0)
            applyRectGradMask(g2,x,y,w,h);
        else if(type==1)
            applyRoundGradMask(g2,x,y,w,h,wa,ha);
        else
            applyLightRoundGradMask(g2,x,y,w,h,wa,ha);
    }
    /**
     *
     * @param g2
     * @param x
     * @param y
     * @param w
     * @param h
     */
    public void applyRectGradMask(Graphics2D g2,int x,int y,int w,int h){
        GradientPaint p=new GradientPaint(0,0,new Color(1.0f,1.0f,1.0f,1.0f),0,h/2,new Color(1.0f,1.0f,1.0f,0.5f));
        g2.setPaint(p);
        g2.fillRect(x,y,w,h/2);
        p=new GradientPaint(0,0,new Color(1.0f,1.0f,1.0f,0.1f),0,30,new Color(1.0f,1.0f,1.0f,0.1f));
        g2.setPaint(p);
        g2.fillRect(x,y+h/2,w,h/2);
    }
    /**
     *
     * @param g2
     * @param x
     * @param y
     * @param w
     * @param h
     * @param wa
     * @param ha
     */
    public void applyRoundGradMask(Graphics2D g2,int x,int y,int w,int h,int wa,int ha){
        GradientPaint p=new GradientPaint(0,0,new Color(1.0f,1.0f,1.0f,1.0f),0,h/2,new Color(1.0f,1.0f,1.0f,0.5f));
        g2.setPaint(p);
        g2.fillRoundRect(x,y,w,h/3,wa,ha);
        p=new GradientPaint(0,0,new Color(1.0f,1.0f,1.0f,0.1f),0,30,new Color(1.0f,1.0f,1.0f,0.1f));
        g2.setPaint(p);
        g2.fillRoundRect(x,y+h/3,w,2*h/3,wa,ha);
    }
    /**
     *
     * @param g2
     * @param x
     * @param y
     * @param w
     * @param h
     * @param wa
     * @param ha
     */
    public void applyLightRoundGradMask(Graphics2D g2,int x,int y,int w,int h,int wa,int ha){
        GradientPaint p=new GradientPaint(0,0,new Color(1.0f,1.0f,1.0f,1.0f),0,h/2,new Color(1.0f,1.0f,1.0f,0.2f));
        g2.setPaint(p);
        g2.fillRoundRect(x,y,w,h/2,wa,ha);
        p=new GradientPaint(0,0,new Color(1.0f,1.0f,1.0f,0.1f),0,30,new Color(1.0f,1.0f,1.0f,0.1f));
        g2.setPaint(p);
        g2.fillRoundRect(x,y+h/2,w,h/2,wa,ha);
    }
}

